package trabajoISW2.tests;

import java.util.Calendar;

import org.junit.Before;
import org.junit.Test;

import trabajoISW2.domain.exceptions.NoPositiveNumberException;
import trabajoISW2.domain.exceptions.WrongNameException;
import trabajoISW2.domain.implementations.Author;
import trabajoISW2.domain.implementations.Book;
import trabajoISW2.domain.implementations.Publisher;
import trabajoISW2.domain.implementations.Subject;


public class BookTestSuite {
	
	Book b;
	Long n1, n2, n3, n4, n5, n6;
	Author a;
	Publisher p;
	Subject s;
	SuperTest st;
	
	@Before
	public void setup(){
		st = new SuperTest();
		st.inicializa();
		b = st.book1;
		n1 = new Long(-1);
		n2 = Long.MAX_VALUE;
	}
	
	//Tests setIsbn()
	
	@Test
	public void testSetIsbn(){
		b.setIsbn("1111111111");
		b.setIsbn("1111111111111");
		
	}
	
	@Test(expected = IllegalArgumentException.class)
	public void testSetIsbn1(){
		b.setIsbn("11111111");
		
	}
	
	@Test(expected = IllegalArgumentException.class)
	public void testSetIsbn2(){
		b.setIsbn("11111111111");
		
	}
	
	@Test(expected = IllegalArgumentException.class)
	public void testSetIsbn3(){
		b.setIsbn("111111111111");
		
	}
	
	@Test(expected = IllegalArgumentException.class)
	public void testSetIsbn4(){
		b.setIsbn("11111111111111");
		
	}
	
	@Test(expected = IllegalArgumentException.class)
	public void testSetIsbn5(){
		b.setIsbn(null);
		
	}
	
	
	
	//Tests setTitle
	
	@Test
	public void testSetTitle(){
		b.setTitle("prueba");
				
	}
	
	@Test(expected = WrongNameException.class)
	public void testSetTitle1(){
		b.setTitle(null);
	}
	@Test(expected = WrongNameException.class)
	public void testSetTitle2(){
		b.setTitle("");
	}
	
	
	//Tests setPrice
	
	@Test
	public void testSetPrice(){
		b.setPrice(0);
		b.setPrice(Double.MAX_VALUE);
		b.setPrice(Double.MAX_VALUE - Double.MIN_VALUE);
	}
	
	@Test(expected = NoPositiveNumberException.class)
	public void testSetPrice1(){
		b.setPrice(-Double.MIN_VALUE);
	}
	
	@Test(expected = NoPositiveNumberException.class)
	public void testSetPrice2(){
		b.setPrice(-Double.MAX_VALUE + Double.MIN_VALUE);
	}
	
	@Test(expected = NoPositiveNumberException.class)
	public void testSetPrice3(){
		b.setPrice(-Double.MAX_VALUE);
	}
	
	
	//Tests setSummary
	
	@Test
	public void testSetSummary(){
		b.setSummary("prueba");
				
	}
	
	@Test(expected = WrongNameException.class)
	public void testSetSummary1(){
		b.setSummary(null);
	}
	@Test(expected = WrongNameException.class)
	public void testSetSummary2(){
		b.setSummary("");
	}
	
	
	//Tests setLanguage
	
	@Test
	public void testSetLanguage(){
		b.setLanguage("prueba");
				
	}
	
	@Test(expected = WrongNameException.class)
	public void testSetLanguage1(){
		b.setLanguage(null);
	}
	@Test(expected = WrongNameException.class)
	public void testSetLanguage2(){
		b.setLanguage("");
	}
	
	//Tests setYear
	
	@Test
	public void testSetYear(){
		b.setYear(1);
		b.setYear(Calendar.YEAR);
		b.setYear(Calendar.YEAR);
	}
	
	@Test(expected = NoPositiveNumberException.class)
	public void testSetYear1(){
		b.setYear(0);
	}
	@Test(expected = NoPositiveNumberException.class)
	public void testsetYear2(){
		b.setYear(-1);
	}
	
	@Test(expected = NoPositiveNumberException.class)
	public void testSetYear3(){
		b.setYear(Integer.MIN_VALUE);
	}
	@Test(expected = NoPositiveNumberException.class)
	public void testSetYear4(){
		b.setYear(Integer.MIN_VALUE + 1);
	}
	
	
	//Test setAuthor
	
	@Test
	public void testSetAuthor(){
		b.setAuthor(new Author());
	}
	
	@Test(expected = IllegalArgumentException.class)
	public void testSetAuthor1(){
		b.setAuthor(null);
	}
	
	//Test setPublisher
	
	@Test
	public void testSetPublisher(){
		b.setPublisher(new Publisher());
	}
	
	@Test(expected = IllegalArgumentException.class)
	public void testSetPublisher1(){
		b.setPublisher(null);
	}
	
	//Test setAuthor
	
	@Test
	public void testSetSubject(){
		b.setSubject(new Subject());
	}
	
	@Test(expected = IllegalArgumentException.class)
	public void testSetSubject1(){
		b.setSubject(null);
	}

}
